<?php
//------------------------------------------------------------------------------
// File 			  : V_SanphamView
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.15         Oanhhtk                         Created
//------------------------------------------------------------------------------
global $strtooltip ;
$strtooltip = "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
function V_SanphamView(&$arrayData,&$arrayData2){
	global $LANG,$db, $objModel, $strtooltip;
    $ulr = "?".MODUL."=sanpham&".ACTION."=";
	//hang sx
	include_once(DIR_MODEL."md_hang_sx.class.php");
	$objHangsx = new MD_Hangsx($db);
	//loai san pham
	include_once(DIR_MODEL."md_cat_san_pham.class.php");
	$objcatSanpham = new MD_CatSanpham($db);
	
	include_once(DIR_MODEL."md_album_san_pham.class.php");
	$album_sp = new MD_AlbumSanpham($db);
	$array_album = $album_sp->getByWhere('*','id_sanpham='.$arrayData["id"],'');
?>
<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top">
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif);">
<?=$arrayData['ten_sp']?>
</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table border="0" cellspacing="5" cellpadding="0" width="100%" class="khung_home">
	<tr>
		<td width="188" valign="top">
			<link type="text/css" rel="stylesheet" href="../css/image-slideshow.css">
			<script type="text/javascript" language="javascript" src="../javascript/image-slideshow.js"></script>
			<div id="dhtmlgoodies_slideshow">
				<div id="previewPane">
					<img src="../admin/images/images_upload/<?=$arrayData["anh_sp"]?>"/>
					<span id="waitMessage"></span>	
					<div id="largeImageCaption"></div>
				</div><!-- previewPane -->
				<div id="galleryContainer">
					<div id="arrow_left"><img src="../images/arrow_left.gif"></div>
					<div id="arrow_right"><img src="../images/arrow_right.gif"></div>
					<div id="theImages">
							<!-- Thumbnails -->
							<?
							$stt = 1;
							foreach($array_album as $rowAlbum){
							?>
							<a href="#" onclick="showPreview('../admin/images/images_upload/img_album_san_pham/<?=$rowAlbum['ten_anh']?>','<?=$stt?>');return false">
							<img src="../admin/images/images_upload/img_album_san_pham/<?=$rowAlbum['ten_anh']?>">
							</a>	
							<div class="imageCaption"></div>	
							<?
								$stt ++;
							}
							?>
							<!-- End thumbnails -->
							
							<div id="slideEnd"></div>
					</div>
				</div><!-- galleryContainer -->
			</div><!-- dhtmlgoodies_slideshow -->
		</td>
		<td width="832" valign="top">
			<table width="100%" cellpadding="0" cellspacing="0" style="line-height:18px; padding-right:5px; text-align:justify; ">
				<tr>
					<td class="cat_ten_sp">						
						<span style="text-transform:uppercase; "><?=$arrayData['ten_sp']?></span>
					</td>
				</tr>
				<!-- <tr>
					<td>
						< ?=$arrayData['mo_ta_sp']?>
					</td>
				</tr> -->
				<?
				if($arrayData['gia_sp_km']>0){
				?>
				<tr>
					<td>
						<span class="ten_gia">Giá cũ:&nbsp;&nbsp;</span><span class="gia_cu"><?=to_money($arrayData['gia_sp'])?> VNĐ</span>
					</td>
				</tr>
				<tr>
					<td>
						<span class="ten_gia">Chỉ còn:&nbsp;</span><span class="gia_moi"><?=to_money($arrayData['gia_sp_km'])?> VNĐ</span>
					</td>
				</tr>
				<?
				}else{
				?>
				<tr>
					<td>
						<span class="ten_gia">Giá:&nbsp;</span><span class="gia_moi"><?=to_money($arrayData['gia_sp'])?> VNĐ</span>
					</td>
				</tr>
				<?
				}
				?>
				<tr>
					<td>
						<span class="ten_gia">Bảo hành:&nbsp;</span><span class="baohanh"><?=$arrayData['bao_hanh']?> tháng</span>
					</td>
				</tr>
				<?
				if($arrayData['gia_sp_km']>0){
				?>
				<tr><td>&nbsp;</td></tr>
				<tr>
					<td>
						<span class="title_khuyenmai">KHUYẾN MẠI: </span><span class="khuyenmai"><?=$arrayData['ghi_chu']?></span>
					</td>
				</tr>
				<?
				}
				?>
				<tr>
					<td>
						<span class="muangay"><a href="?modul=giohang&action=View&id=<?=$arrayData["id"]?>">Mua ngay</a></span>
					</td>
				</tr>
			</table>
		</td>
		
	</tr>
	
</table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
<BR>
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif);">
	THÔNG SỐ KỸ THUẬT
</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table width="100%" cellpadding="0" cellspacing="0" class="khung_home" style="padding:10px">
	<tr>
		<td align="justify">
			<?=$arrayData['chi_tiet_sp']?>
		</td>
	</tr>
</table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
</td>
<td width="10px">&nbsp;</td>
<td valign="top" width="200px">
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif);">Sản phẩm cùng loại</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table border="0" cellspacing="10" cellpadding="0" width="100%" class="khung_home"><tr><td>
<?
if (empty($arrayData2)){
	echo "Không có sản phẩm cùng loại.";
}else{
?>
<div class="slide_detail_sp">
	<ul style="width:100%; margin:0; padding:0;"  class="detail_sp">
<?
	$stt=0;
	foreach ($arrayData2 as $row)
	{
		$ngaunhien = time().rand();
		$strtooltip .= "<div id=\"".$ngaunhien."\" class=\"atip\" style=\"width:200px\"><div class=\"stickytitle\">".$row['ten_sp']."</div><div style=\"padding:5px\">".$row["mo_ta_sp"]."</div></div>";
		$stt ++;
?>
		<li <? if($stt >2){ ?> style="display:none;" <? } ?>>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td align="center">
						<a href="?modul=sanpham&action=View&id_loai_sp=<?=$arrayData["id_loai_sp"]?>&id=<?=$row["id"]?>" 
						style="color:#007DEB; font-size:11px; font-weight:bold; text-transform:uppercase; ">
							<?=$row["ten_sp"]?>
						</a>
					</td>
				</tr>
				<tr>
					<td align="center">
						<a href="?modul=sanpham&action=View&id_loai_sp=<?=$arrayData["id_loai_sp"]?>&id=<?=$row["id"]?>" >
						<?
						if(!empty($row['anh_sp'])){
							$exists = file_exists('../admin/images/images_upload/'.$row['anh_sp']);
							if($exists){
						?>
						<img src="<?=DIR_IMAGES_VIEW.$row['anh_sp']?>" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; " data-tooltip="<?=$ngaunhien?>" />
						<?
							}else{
						?>
							<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien?>"/>
						<?
							}
						}else{
						?>
						<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien?>"/>
						<?
						}
						?>
						</a>
					</td>
				</tr>
				<tr>
					<td>
						<?
						if($row['gia_sp_km']>0){
						?>
						<span class="ten_gia" style="padding-left:10px; ">Giá cũ:&nbsp;&nbsp;</span><span class="gia_cu"><?=to_money($row['gia_sp_km'])?> VNĐ</span><br />
						<span class="ten_gia" style="padding-left:10px; ">Chỉ còn:&nbsp;</span><span class="gia_moi"><?=to_money($row['gia_sp'])?> VNĐ</span><br /><br />
						<?
						}else{
						?>
						<span class="ten_gia" style="padding-left:10px; ">Giá:&nbsp;</span><span class="gia_moi"><?=to_money($row['gia_sp'])?> VNĐ</span><br /><br />
						<?
						}
						?>
						<span class="chitiet_sp" style="float:right; padding-right:20px; ">
						<a href="?modul=sanpham&action=View&id_loai_sp=<?=$arrayData['id_loai_sp']?>&id=<?=$row['id']?>">Chi tiết</a>
						</span>
					</td>
				</tr>
				
				<tr>
					<td>
						<hr style="border-bottom:0.1em solid #FF0000;" />
					</td>
				</tr>
			</table>
		</li>
		<div style=\"clear:both\"></div>
<?
	}//end foreach
?>
	</ul>
	<?
	if(count($arrayData2) > 2){
	?>
	<p align="center" style="padding-top:5px; "><a href="javascript:void(0)" class="go-prev"> << Trước</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="go-next">Sau >></a></p>
	<?
	}
	?>
</div><!-- slide_detail_sp -->
<script>
$(function(){
   $.fn.extend.options = {  
		num_rows: 2,
		class_name: 'detail_sp'
	};
	$(".slide_detail_sp").simpleSlider();
});
</script>
<?
}
?>

</td></tr></table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
<br />
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif);">Sản phẩm mới nhất</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table border="0" cellspacing="10" cellpadding="0" width="100%" class="khung_home">
<?php
	$spmoi = $objModel->getFirstByWhere('*','','ngay_dang DESC');
	$catSPMoi = $objcatSanpham->getById2($spmoi["id_loai_sp"]);
	$ngaunhien_moi = time().rand();
	$strtooltip .= "<div id=\"".$ngaunhien_moi."\" class=\"atip\" style=\"width:200px\">
					<div class=\"stickytitle\">".$spmoi['ten_sp']."</div>
					<div style=\"padding:5px\">".$spmoi["mo_ta_sp"]."</div>
					</div>";
	
?>
	<tr>
		<td align="center">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spmoi["id_loai_sp"]?>&id=<?=$spmoi["id"]?>" 
			style="color:#007DEB; font-size:11px; font-weight:bold; text-transform:uppercase; ">
				<?=$spmoi["ten_sp"]?>
			</a>
		</td>
	</tr>
	<tr>
		<td align="center">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spmoi["id_loai_sp"]?>&id=<?=$spmoi["id"]?>" >
			<?
			if(!empty($spmoi['anh_sp'])){
				$exists_spm = file_exists('../admin/images/images_upload/'.$spmoi['anh_sp']);
				if($exists_spm){
			?>
			<img src="<?=DIR_IMAGES_VIEW.$spmoi['anh_sp']?>" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; " data-tooltip="<?=$ngaunhien_moi?>" />
			<?
				}else{
			?>
				<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien_moi?>"/>
			<?
				}
			}else{
			?>
			<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien_moi?>"/>
			<?
			}
			?>
			</a>
		</td>
	</tr>
	<tr>
		<td>
			<?
			if($spmoi['gia_sp_km']>0){
			?>
			<span class="ten_gia" style="padding-left:10px; ">Giá cũ:&nbsp;&nbsp;</span><span class="gia_cu"><?=to_money($spmoi['gia_sp_km'])?> VNĐ</span><br />
			<span class="ten_gia" style="padding-left:10px; ">Chỉ còn:&nbsp;</span><span class="gia_moi"><?=to_money($spmoi['gia_sp'])?> VNĐ</span><br /><br />
			<?
			}else{
			?>
			<span class="ten_gia" style="padding-left:10px; ">Giá:&nbsp;</span><span class="gia_moi"><?=to_money($spmoi['gia_sp'])?> VNĐ</span><br /><br />
			<?
			}
			?>
			<span class="chitiet_sp" style="float:right; padding-right:20px; ">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spmoi['id_loai_sp']?>&id=<?=$spmoi['id']?>">Chi tiết</a>
			</span>
			
		</td>
	</tr>
	<tr>
		<td>
			<hr style="border-bottom:0.1em solid #FF0000;" />
		</td>
	</tr>
	<tr>
		<td>
			<span style="float:right; padding-right:5px;">
			<a href="?modul=sanpham&action=List&id_loai_sp=<?=$spmoi['id_loai_sp']?>&parent_id=<?=$catSPMoi['parent_id']?>" style="color:#007DEB; ">Xem thêm <img src="../images/icon_tenred.gif"></a>
			</span>
		</td>
	</tr>
	
</table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
<br />
<div class="title" style="margin-left:10px; width:10px; height:30px; float:left"></div>
<p style="float:left; line-height:30px; font-weight:bold; color:#FFFFFF; background: url(../images/modul_c.gif);">Sản phẩm bán chạy</p>
<div class="title2" style="width:10px; height:30px; float:left"></div>
<div style="clear:both"></div>
<div class="bg_l_t"><div class="bg_r_t"><div class="bg_c_t"></div></div></div>
<table border="0" cellspacing="10" cellpadding="0" width="100%" class="khung_home">
<?php
	$spbanchay = $objModel->getFirstByWhere('*','','solanban DESC');
	$catSPBC = $objcatSanpham->getById2($spbanchay["id_loai_sp"]);
	$ngaunhien_bc = time().rand();
	$strtooltip .= "<div id=\"".$ngaunhien_bc."\" class=\"atip\" style=\"width:200px\"><div class=\"stickytitle\">".$spbanchay['ten_sp']."</div><div style=\"padding:5px\">".$spbanchay["mo_ta_sp"]."</div></div>";
?>
	<tr>
		<td align="center">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spbanchay["id_loai_sp"]?>&id=<?=$spbanchay["id"]?>" 
			style="color:#007DEB; font-size:11px; font-weight:bold; text-transform:uppercase; ">
				<?=$spbanchay["ten_sp"]?>
			</a>
		</td>
	</tr>
	<tr>
		<td align="center">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spbanchay["id_loai_sp"]?>&id=<?=$spbanchay["id"]?>" >
			<?
			if(!empty($spbanchay['anh_sp'])){
				$exists_spbc = file_exists('../admin/images/images_upload/'.$spbanchay['anh_sp']);
				if($exists_spbc){
			?>
			<img src="<?=DIR_IMAGES_VIEW.$spbanchay['anh_sp']?>" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; " data-tooltip="<?=$ngaunhien_bc?>" />
			<?
				}else{
			?>
				<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien_bc?>"/>
			<?
				}
			}else{
			?>
			<img src="../images/no_image_130.jpg"  class="image_thumb_news" width="80px" height="80px" style="padding-bottom:5px; padding-top:5px; "  data-tooltip="<?=$ngaunhien_bc?>"/>
			<?
			}
			?>
			</a>
		</td>
	</tr>
	<tr>
		<td>
			<?
			if($spbanchay['gia_sp_km']>0){
			?>
			<span class="ten_gia" style="padding-left:10px; ">Giá cũ:&nbsp;&nbsp;</span><span class="gia_cu"><?=to_money($spbanchay['gia_sp_km'])?> VNĐ</span><br />
			<span class="ten_gia" style="padding-left:10px; ">Chỉ còn:&nbsp;</span><span class="gia_moi"><?=to_money($spbanchay['gia_sp'])?> VNĐ</span><br /><br />
			<?
			}else{
			?>
			<span class="ten_gia" style="padding-left:10px; ">Giá:&nbsp;</span><span class="gia_moi"><?=to_money($spbanchay['gia_sp'])?> VNĐ</span><br /><br />
			<?
			}
			?>
			<span class="chitiet_sp" style="float:right; padding-right:20px; ">
			<a href="?modul=sanpham&action=View&id_loai_sp=<?=$spbanchay['id_loai_sp']?>&id=<?=$spbanchay['id']?>">Chi tiết</a>
			</span>
			
		</td>
	</tr>
	<tr>
		<td>
			<hr style="border-bottom:0.1em solid #FF0000;" />
		</td>
	</tr>
	<tr>
		<td>
			<span style="float:right; padding-right:5px;">
			<a href="?modul=sanpham&action=List&id_loai_sp=<?=$spbanchay['id_loai_sp']?>&parent_id=<?=$catSPBC['parent_id']?>" style="color:#007DEB; ">Xem thêm <img src="../images/icon_tenred.gif"></a>
			</span>
		</td>
	</tr>
	<?
	echo $strtooltip ;
	?>
</table>
<div class="bg_l_b"><div class="bg_r_b"><div class="bg_c_b"></div></div></div>
</td></tr></table>
<script type="text/javascript">stickytooltip.init("*[data-tooltip]", "mystickytooltip")</script>
<?
}
?>